package com.ddxz.hospital.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.ddxz.hospital.dto.*;
import com.ddxz.hospital.entity.*;
import com.ddxz.hospital.mapper.InputMapper;
import com.ddxz.hospital.service.InputService;
import com.ddxz.hospital.util.Desc2Code;
import com.ddxz.hospital.util.ErrorStatus;
import com.ddxz.tool.core.common.CommonUtil;
import com.ddxz.tool.core.common.DdxzJwtUtil;
import com.ddxz.tool.core.convert.BeanUtil;
import com.ddxz.tool.core.convert.StringUtil;
import com.ddxz.tool.core.security.Base64Util;
import com.ddxz.tool.web.common.ConstData;
import com.ddxz.tool.web.dto.DdxzResponse;
import com.ddxz.tool.web.dto.PageResponse;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import static com.ddxz.hospital.util.ErrorStatus.*;
import static com.ddxz.hospital.util.ExcelIndex.*;

/**
 * class description
 *
 * @author 朱宗刚
 * @version 1.0.0
 * @date 2020/9/23
 */

@Service
public class InputServiceImpl implements InputService {
    /**
     * 保存病人信息
     *
     * @param token   令牌
     * @param patient 病人信息
     * @return 是否保存成功
     */
    @Override
    public DdxzResponse patientSave(String token, PatientVO patient) {
        String userName = this.getUserName(token);
        if (userName == null) {
            logger.error("解析令牌失败", token);
            return DdxzResponse.error(INVALID_TOKEN);
        } else {
            PatientEntity entity = new PatientEntity();
            BeanUtils.copyProperties(patient, entity);
            entity.setModifyTime(System.currentTimeMillis());

            Integer res;
            if (patient.getId() == null) {
                entity.setId(CommonUtil.generatorId("t_patient"));
                res = this.mapper.savePatient(entity);
            } else {
                res = this.mapper.modifyPatient(entity);
            }

            return res > 0 ? DdxzResponse.correct(entity.getId()) : DdxzResponse.error(FAILD_SAVE_PATIENT);
        }
    }

    /**
     * 保存住院信息
     *
     * @param token     令牌
     * @param patientId 病人标识
     * @param consult   住院信息
     * @return 是否保存成功
     */
    @Override
    public DdxzResponse consultSave(String token, String patientId, ConsultVO consult) {
        String userName = this.getUserName(token);
        if (userName == null) {
            logger.error("解析令牌失败", token);
            return DdxzResponse.error(INVALID_TOKEN);
        } else {
            IndicateEntity indicate = new IndicateEntity(1, patientId);
            BeanUtils.copyProperties(consult, indicate);
            indicate.setModifyTime(System.currentTimeMillis());
            indicate.setTreatPlan(this.toJson(consult.getTreatPlan()));
            ConsultEntity entity = new ConsultEntity();
            BeanUtils.copyProperties(consult, entity);
            if (consult.getId() == null || consult.getId().trim().length() < 1) {
                indicate.setId(CommonUtil.generatorId("t_consult"));
                entity.setId(indicate.getId());
            }
            entity.setWaistHeight(Desc2Code.getWaistHeight(entity.getWaistline(), indicate.getHeight()));
            indicate.setMbi(Desc2Code.getBMI(indicate.getHeight(), indicate.getWeight()));

            indicate.setPatientId(patientId);
            ErrorStatus es = this.checkIndicate(indicate);
            if (CHECK_PASS != es) {
                return DdxzResponse.error(es);
            } else {
                es = this.checkConsult(entity, indicate);
                if (CHECK_PASS != es) {
                    return DdxzResponse.error(es);
                } else {
                    Integer rst = consult.getId() != null && consult.getId().trim().length() >= 1 ?
                            this.mapper.modifyIndicate(indicate) + this.mapper.modifyConsult(entity) :
                            this.mapper.saveIndicate(indicate) + this.mapper.saveConsult(entity);
                    return rst > 0 ? DdxzResponse.correct(entity.getId()) : DdxzResponse.error(FAILD_SAVE_CONSULT);
                }
            }
        }
    }

    /**
     * 保存随访信息
     *
     * @param token     令牌
     * @param patientId 病人标识
     * @param course    随访信息
     * @return 是否保存成功
     */
    @Override
    public DdxzResponse courseSave(String token, String patientId, CourseVO course) {
        String userName = this.getUserName(token);
        if (userName == null) {
            logger.error("解析令牌失败", token);
            return DdxzResponse.error(ErrorStatus.INVALID_TOKEN);
        } else {
            IndicateEntity indicate = new IndicateEntity(2, patientId);
            BeanUtils.copyProperties(course, indicate);
            indicate.setModifyTime(System.currentTimeMillis());
            CourseEntity entity = new CourseEntity();
            BeanUtils.copyProperties(course, entity);
            if (course.getId() == null || course.getId().trim().length() < 1) {
                indicate.setId(CommonUtil.generatorId("t_course"));
                entity.setId(indicate.getId());
            }
            indicate.setMbi(Desc2Code.getBMI(indicate.getHeight(), indicate.getWeight()));

            ErrorStatus es = this.checkIndicate(indicate);
            if (CHECK_PASS != es) {
                return DdxzResponse.error(es);
            } else {
                indicate.setPatientId(patientId);
                Integer rst = course.getId() != null && course.getId().trim().length() >= 1 ?
                        this.mapper.modifyIndicate(indicate) + this.mapper.modifyCourse(entity) :
                        this.mapper.saveIndicate(indicate) + this.mapper.saveCourse(entity);
                return rst > 0 ? DdxzResponse.correct(entity.getId()) : DdxzResponse.error(ErrorStatus.FAILD_SAVE_COURSE);
            }
        }
    }

    /**
     * 获取病人详情
     *
     * @param token     令牌
     * @param patientId 病人标识
     * @return 病人详情
     */
    @Override
    public DdxzResponse patientDetail(String token, String patientId) {
        String userName = this.getUserName(token);
        if (userName == null) {
            logger.error("解析令牌失败", token);
            return DdxzResponse.error(INVALID_TOKEN);
        } else {
            PatientEntity entity = this.mapper.getPatientDetail(patientId);
            if (entity == null) {
                logger.error("病人不存在");
                return DdxzResponse.error(PATIENT_NOT_EXISTS);
            } else {
                PatientVO patient = new PatientVO();
                BeanUtils.copyProperties(entity, patient);
                return DdxzResponse.correct(patient);
            }
        }
    }

    /**
     * 获取住院信息
     *
     * @param token     令牌
     * @param consultId 住院标识
     * @return 住院信息
     */
    @Override
    public DdxzResponse consultDetail(String token, String consultId) {
        String userName = this.getUserName(token);
        if (userName == null) {
            logger.error("解析令牌失败", token);
            return DdxzResponse.error(INVALID_TOKEN);
        } else {
            IndicateEntity indicate = this.mapper.getIndicateDetail(consultId);
            ConsultEntity entity = this.mapper.getConsultDetail(consultId);
            if (indicate != null && entity != null) {
                ConsultVO consult = new ConsultVO();
                BeanUtils.copyProperties(indicate, consult);
                BeanUtils.copyProperties(entity, consult);
                consult.setTreatPlan(this.toPlan(indicate.getTreatPlan()));
                return DdxzResponse.correct(consult);
            } else {
                logger.error("病人住院门诊信息不存在");
                return DdxzResponse.error(CONSULT_NOT_EXISTS);
            }
        }
    }

    /**
     * 获取随访信息
     *
     * @param token    令牌
     * @param courseId 随访标识
     * @return 随访信息
     */
    @Override
    public DdxzResponse courseDetail(String token, String courseId) {
        String userName = this.getUserName(token);
        if (userName == null) {
            logger.error("解析令牌失败", token);
            return DdxzResponse.error(INVALID_TOKEN);
        } else {
            IndicateEntity indicate = this.mapper.getIndicateDetail(courseId);
            CourseEntity domain = this.mapper.getCourseDetail(courseId);
            if (null != indicate && null != domain) {
                CourseVO course = new CourseVO();
                BeanUtils.copyProperties(indicate, course);
                BeanUtils.copyProperties(domain, course);
                course.setTreatPlan(this.toPlan(indicate.getTreatPlan()));
                return DdxzResponse.correct(course);
            } else {
                logger.error("病人门诊随访信息不存在");
                return DdxzResponse.error(COURSE_NOT_EXISTS);
            }
        }
    }

    /**
     * 分页检索病人信息
     *
     * @param token 令牌
     * @param page  页码
     * @param size  每页病人数
     * @param name  病人姓名
     * @param phone 手机号码
     * @return 病人清单
     */
    @Override
    public DdxzResponse patientList(String token, Integer page, Integer size, String name, String phone) {
        String userName = this.getUserName(token);
        if (userName == null) {
            logger.error("解析令牌失败", token);
            return DdxzResponse.error(ErrorStatus.INVALID_TOKEN);
        } else {
            PageHelper.startPage(page, size);
            Page<PatientSearch> patientList = this.mapper.getPatientList(name, phone);
            if (patientList == null) {
                logger.warn("无病人数据");
                return DdxzResponse.correct(PageResponse.getInstance(PatientSearch.class));
            } else {
                return DdxzResponse.correct(PageResponse.getInstance(patientList, PatientSearch.class));
            }
        }
    }

    /**
     * 分页检索病人治疗信息
     *
     * @param token     令牌
     * @param patientId 病人标识
     * @param beginDate 检索起始日期
     * @param endDate   检索结束日期
     * @param type      检索类型
     * @param page      页码
     * @param size      每页治疗条数
     * @return 治疗清单
     */
    @Override
    public DdxzResponse cureList(String token, String patientId, String beginDate, String endDate, Integer type, Integer page, Integer size) {
        String userName = this.getUserName(token);
        if (userName == null) {
            logger.error("解析令牌失败", token);
            return DdxzResponse.error(ErrorStatus.INVALID_TOKEN);
        } else if (type >= 0 && type <= 2) {
            Page<CureEntity> cureEntrty = this.mapper.getCureList(patientId, type, beginDate, endDate);
            if (null != cureEntrty && cureEntrty.size() >= 1) {
                PageResponse<CureSearch> response = new PageResponse<>(cureEntrty.getResult().size());
                cureEntrty.getResult().forEach(item -> {
                    CureSearch search = BeanUtil.getTarget(item, CureSearch.class);
                    search.setPlanList(toPlan(item.getTreatPlan()));
                    response.getContent().add(search);
                });
                return DdxzResponse.correct(response);
            } else {
                logger.warn("病人无数据");
                return DdxzResponse.correct(PageResponse.getInstance(CureSearch.class));
            }
        } else {
            logger.error("无效的问诊类型");
            return DdxzResponse.error(ErrorStatus.INVALID_CURE_TYPE);
        }
    }

    /**
     * 登陆系统
     *
     * @param loginInfo 登陆信息
     * @return 令牌
     */
    @Override
    public DdxzResponse login(LoginInfo loginInfo) {
        if ("admin".equals(loginInfo.getUsername()) && "admin@123".equals(loginInfo.getPassword())) {
            Map<String, Object> claim = new HashMap<>(1);
            claim.put("username", loginInfo.getUsername());
            return DdxzResponse.correct(jwtUtil.getToken(claim));
        } else {
            return DdxzResponse.error(PASSWORD_NOT_MATCH);
        }
    }

    /**
     * 更新令牌信息
     *
     * @param token 旧令牌
     * @return 新令牌
     */
    @Override
    public DdxzResponse pong(String token) {
        Map<String, Object> claim = jwtUtil.getBody(token);
        if (claim == null) {
            return DdxzResponse.error(INVALID_TOKEN);
        } else {
            return DdxzResponse.correct(jwtUtil.getToken(claim));
        }
    }

    /**
     * 移除病人信息
     *
     * @param token     令牌
     * @param patientId 病人标识
     * @return 是否移除成功
     */
    @Override
    public DdxzResponse removePatient(String token, String patientId) {
        String userName = this.getUserName(token);
        if (userName == null) {
            logger.error("解析令牌失败", token);
            return DdxzResponse.error(ErrorStatus.INVALID_TOKEN);
        } else {
            Integer res = this.mapper.removePatient(patientId);
            List<String> cids = this.mapper.getCureIds(patientId);
            if (cids != null && cids.size() >= 1) {
                res += this.mapper.removeIndicates(cids);
                res += this.mapper.removeConsults(cids);
                res += this.mapper.removeCourses(cids);
                return res > 0 ? DdxzResponse.correct(ConstData.OK_MESSAGE) : DdxzResponse.error(ErrorStatus.FAILD_REMOVE_PATIENT);
            } else {
                return DdxzResponse.correct(ConstData.OK_MESSAGE);
            }
        }
    }

    /**
     * 移除治疗信息
     *
     * @param token 令牌
     * @param curId 质量标识
     * @return 是否移除成功
     */
    @Override
    public DdxzResponse removeCure(String token, String curId) {
        String userName = this.getUserName(token);
        if (userName == null) {
            logger.error("解析令牌失败", token);
            return DdxzResponse.error(ErrorStatus.INVALID_TOKEN);
        } else {
            this.mapper.removeIndicate(curId);
            this.mapper.removeConsult(curId);
            this.mapper.removeCourse(curId);
            return DdxzResponse.correct(ConstData.OK_MESSAGE);
        }
    }

    /**
     * 导入病人信息
     *
     * @param token 令牌
     * @param file  保存有病人信息的Excel文件
     * @return 是否导入成功
     */
    @Override
    public DdxzResponse importPatient(String token, MultipartFile file) {
        String userName = this.getUserName(token);
        if (userName == null) {
            logger.error("解析令牌失败", token);
            return DdxzResponse.error(INVALID_TOKEN);
        } else {
            boolean old = file.getOriginalFilename().endsWith(".xls");
            Integer count = 0;

            try {
                Workbook workbook = old ? new HSSFWorkbook(file.getInputStream()) : new XSSFWorkbook(file.getInputStream());
                Sheet sheet = ((Workbook) workbook).getSheetAt(0);
                PatientEntity entity = new PatientEntity();

                for (int i = 0; i < sheet.getPhysicalNumberOfRows(); ++i) {
                    if (i >= 2) {
                        Row row = sheet.getRow(i);
                        count = this.mapper.getPatientNumByNameBirthday(Desc2Code.getDesc(getString(row.getCell(A))),
                                getDate(row.getCell(F)), Desc2Code.getHospitalNo(getLongString(row.getCell(B))));
                        if (count <= 0) {
                            entity.setId(CommonUtil.generatorId("t_patient"));
                            entity.setName(Desc2Code.getDesc(null == row.getCell(A) ? null : row.getCell(A).getStringCellValue()));
                            entity.setHospitalized(Desc2Code.getHospitalNo(getLongString(row.getCell(B))));
                            entity.setOldName(Desc2Code.getDesc(null == row.getCell(C) ? "" : row.getCell(C).getStringCellValue()));
                            entity.setGender(Desc2Code.getGenderCode(null == row.getCell(D) ? "" : row.getCell(D).getStringCellValue()));
                            logger.debug("age cell type {}", row.getCell(E).getCellType().toString());
                            entity.setAge(null == row.getCell(E) ? null : row.getCell(E).getNumericCellValue());
                            entity.setBirthday(DFS.format(null == row.getCell(F) ? null : row.getCell(F).getDateCellValue()));
                            entity.setNation(Desc2Code.getNation(null == row.getCell(G) ? "" : row.getCell(G).getStringCellValue()));
                            entity.setAddress(null == row.getCell(H) ? "" : row.getCell(H).getStringCellValue());
                            entity.setAddressType(Desc2Code.getAddressType(null == row.getCell(I) ? "" : row.getCell(I).getStringCellValue()));
                            entity.setConnector(null == row.getCell(J) ? "" : row.getCell(J).getStringCellValue());
                            entity.setRelation(Desc2Code.getRelation(null == row.getCell(K) ? "" : row.getCell(K).getStringCellValue()));
                            logger.debug("count = {}, idx = {}, L type = {}", new Object[]{count, i, row.getCell(L)});
                            entity.setRelationDetail(null == row.getCell(L) ? null : row.getCell(L).getStringCellValue());
                            entity.setMobilePhone(null == row.getCell(M) ? "" : Long.valueOf((long) row.getCell(M).getNumericCellValue()).toString());
                            entity.setInsurance(Desc2Code.getInsurance(null == row.getCell(N) ? "" : row.getCell(N).getStringCellValue()));
                            logger.debug("Homemeters cell type {}", row.getCell(O).getCellType().toString());
                            entity.setHomemeters(getInteger(row.getCell(O)));
                            entity.setSalary(getDouble(row.getCell(P)));
                            entity.setHomeEconomy(Desc2Code.getHomeEconomy(null == row.getCell(Q) ? "" : row.getCell(Q).getStringCellValue()));
                            entity.setCurrentDegree(Desc2Code.getDegree(null == row.getCell(R) ? "" : row.getCell(R).getStringCellValue()));
                            entity.setParentTopDegree(Desc2Code.getParentDegree(null == row.getCell(S) ? "" : row.getCell(S).getStringCellValue()));
                            entity.setParentVocation(Desc2Code.getVocation(null == row.getCell(T) ? "" : row.getCell(T).getStringCellValue()));
                            entity.setParentVocationDetail(null == row.getCell(U) ? "" : row.getCell(U).getStringCellValue());
                            entity.setParentRelation(Desc2Code.getParentRelation(null == row.getCell(V) ? "" : row.getCell(V).getStringCellValue()));
                            entity.setSingleParent(Desc2Code.getJudge(null == row.getCell(W) ? "" : row.getCell(W).getStringCellValue()));
                            entity.setVd(Desc2Code.getJudge(null == row.getCell(X) ? "" : row.getCell(X).getStringCellValue()));
                            entity.setVdMonths(getInteger(row.getCell(Y)));
                            entity.setAntibiotic(Desc2Code.getAntiResult(null == row.getCell(Z) ? "" : row.getCell(Z).getStringCellValue()));
                            entity.setSickness(Desc2Code.getJudge(null == row.getCell(AA) ? "" : row.getCell(AA).getStringCellValue()));
                            entity.setMotherSickness(null == row.getCell(AB) ? "" : row.getCell(AB).getStringCellValue());
                            entity.setBirths(getInteger(row.getCell(AC)));
                            entity.setChilds(getInteger(row.getCell(AD)));
                            entity.setWeeks(Desc2Code.getWeeks(null == row.getCell(AE) ? "" : row.getCell(AE).getStringCellValue()));
                            entity.setDeliverType(Desc2Code.getDeliverType(null == row.getCell(AF) ? "" : row.getCell(AF).getStringCellValue()));
                            entity.setWeight(getDouble(row.getCell(AG)));
                            entity.setFeedType(Desc2Code.getFeedType(null == row.getCell(AH) ? "" : row.getCell(AH).getStringCellValue()));
                            entity.setBreast(getInteger(row.getCell(AI)));
                            entity.setMilkMonths(getInteger(row.getCell(AK)));
                            entity.setFeedMonths(getInteger(row.getCell(AJ)));
                            entity.setElePlaySituation(Desc2Code.getElePlayTime(null == row.getCell(AL) ? "" : row.getCell(AL).getStringCellValue()));
                            entity.setSportSituation(Desc2Code.getSportSituation(null == row.getCell(AM) ? "" : row.getCell(AM).getStringCellValue()));
                            entity.setHistory(Desc2Code.getHistory(getString(row.getCell(AN)),
                                    getString(row.getCell(AO)),
                                    getString(row.getCell(AP)),
                                    getString(row.getCell(AQ)),
                                    getString(row.getCell(AR)),
                                    getString(row.getCell(AS)),
                                    getString(row.getCell(AT)),
                                    getString(row.getCell(AU))));
                            entity.setHistDetail(getString(row.getCell(AV)));
                            logger.debug(entity.toString());
                            this.mapper.savePatient(entity);
                        }
                    }
                }
            } catch (Exception var11) {
                logger.error("导入Excel文件出错", var11);
                return DdxzResponse.error(FAILED_IMPORT_PATIENT);
            }

            return DdxzResponse.correct(ConstData.OK_MESSAGE);
        }
    }

    /**
     * 导入住院信息
     *
     * @param token 令牌
     * @param file  保存有病人住院信息的Excel文件
     * @return 是否导入成功
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public DdxzResponse importConsult(String token, MultipartFile file) {
        String userName = "admin";//this.getUserName(token);
        if (userName == null) {
            logger.error("解析令牌{}失败", token);
            return DdxzResponse.error(ErrorStatus.INVALID_TOKEN);
        } else {
            boolean old = file.getOriginalFilename().endsWith(".xls");
            StringBuilder pName = new StringBuilder();

            try {
                Workbook workbook = old ? new HSSFWorkbook(file.getInputStream()) : new XSSFWorkbook(file.getInputStream());
                Sheet patientInfo = workbook.getSheetAt(0);
                Sheet baseInfo = workbook.getSheetAt(1);
                Sheet checkInfo = workbook.getSheetAt(2);
                Sheet cureInfo = workbook.getSheetAt(3);
                IndicateEntity indicate = new IndicateEntity(1);
                ConsultEntity consult = new ConsultEntity();

                inportPatient(patientInfo);

                for (int i = 0; i < baseInfo.getPhysicalNumberOfRows(); ++i) {
                    if (i >= 2) {
                        Row row = baseInfo.getRow(i);
                        logger.info("第{}行", i);
                        consult.setHospitalized(Desc2Code.getHospitalNo(getLongString(row.getCell(B))));
                        if("0000000000".equals(consult.getHospitalized())) {
                            continue;
                        }

                        consult.setId(CommonUtil.generatorId("t_consult"));
                        indicate.setId(consult.getId());
                        indicate.setType(1);
                        String pid = this.mapper.getPatientIdByHospitalNo(consult.getHospitalized());
                        if (null == pid) {
                            pName.append(", ");
                            pName.append(row.getCell(A).getStringCellValue());
                        } else {
                            indicate.setPatientId(pid);
                            indicate.setCheckDate(getDate(row.getCell(C)));
                            consult.setHospitalizedNum(getInteger(row.getCell(D)));
                            indicate.setDiseaseCourse(getDouble(row.getCell(E)));
                            indicate.setDiseaseUnit(Desc2Code.getDateTimeUnit(getString(row.getCell(F))));
                            consult.setDiagnoseDate(getDate(row.getCell(G)));
                            consult.setFocusFood(Desc2Code.getJudge(getString(row.getCell(H))));
                            consult.setHospitalizedDays(getInteger(row.getCell(I)));
                            consult.setHospitalizedCost(getDouble(row.getCell(J)));
                            indicate.setHeight(getDouble(row.getCell(K)));
                            indicate.setWeight(getDouble(row.getCell(L)));
                            indicate.setMbi(Desc2Code.getBMI(indicate.getHeight(), indicate.getWeight()));
                            consult.setWaistline(getDouble(row.getCell(N)));
                            consult.setHipline(getDouble(row.getCell(O)));
                            consult.setWaistHeight(Desc2Code.getWaistHeight(consult.getWaistline(), indicate.getHeight()));
                            consult.setHeartRate(getInteger(row.getCell(S)));
                            indicate.setSystolicPressure(getDouble(row.getCell(T)));
                            indicate.setDiastolicPressure(getDouble(row.getCell(U)));
                            indicate.setPuberty(Desc2Code.getHas(getString(row.getCell(V))));
                            consult.setDisplayTime(getInteger(row.getCell(W)));
                            consult.setDisplayTimeUnit(Desc2Code.getDateTimeUnit(getString(row.getCell(X))));
                            consult.setSymptom(Desc2Code.getSymptom(getString(row.getCell(Y)),
                                    getString(row.getCell(Z)),
                                    getString(row.getCell(AA)),
                                    getString(row.getCell(AB)),
                                    getString(row.getCell(AC)),
                                    getString(row.getCell(AD)),
                                    getString(row.getCell(AE)),
                                    getString(row.getCell(AF)),
                                    getString(row.getCell(AG)),
                                    getString(row.getCell(AH)),
                                    getString(row.getCell(AI)),
                                    getString(row.getCell(AJ)),
                                    getString(row.getCell(AK)),
                                    getString(row.getCell(AL)),
                                    getString(row.getCell(AM)),
                                    getString(row.getCell(AN)),
                                    getString(row.getCell(AO))));
                            consult.setSign(Desc2Code.getSign(getString(row.getCell(AP)),
                                    getString(row.getCell(AQ)),
                                    getString(row.getCell(AR)),
                                    getString(row.getCell(AS)),
                                    getString(row.getCell(AT)),
                                    getString(row.getCell(AU)),
                                    getString(row.getCell(AV)),
                                    getString(row.getCell(AW)),
                                    getString(row.getCell(AX)),
                                    getString(row.getCell(AY)),
                                    getString(row.getCell(AZ))));
                            consult.setDka(Desc2Code.getDka(getString(row.getCell(BA)),
                                    getString(row.getCell(BB))));
                            row = checkInfo.getRow(i);
                            indicate.setBloodSugar(getDouble(row.getCell(C)));
                            consult.setPrecondition(Desc2Code.getPreconditon(getString(row.getCell(D))));
                            indicate.setCp(getDouble(row.getCell(E)));
                            indicate.setNoneCP(Desc2Code.getJudge(getString(row.getCell(F))));
                            indicate.setInsulin(getDouble(row.getCell(G)));
                            indicate.setNoneInsulin(Desc2Code.getJudge(getString(row.getCell(H))));
                            indicate.setCruorin(getDouble(row.getCell(I)));
                            indicate.setNoneCruorin(Desc2Code.getJudge(getString(row.getCell(J))));
                            indicate.setRicim(getDouble(row.getCell(K)));
                            indicate.setNoneRicim(Desc2Code.getJudge(getString(row.getCell(L))));
                            indicate.setRericim(getDouble(row.getCell(M)));
                            indicate.setNoneRericim(Desc2Code.getJudge(getString(row.getCell(N))));
                            indicate.setPh(getDouble(row.getCell(O)));
                            indicate.setNonePH(Desc2Code.getJudge(getString(row.getCell(P))));
                            indicate.setHco3(getDouble(row.getCell(Q)));
                            indicate.setNoneHco3(Desc2Code.getJudge(getString(row.getCell(R))));
                            indicate.setBe(getDouble(row.getCell(S)));
                            indicate.setNoneBe(Desc2Code.getJudge(getString(row.getCell(T))));
                            indicate.setNa(getDouble(row.getCell(U)));
                            indicate.setNoneNa(Desc2Code.getJudge(getString(row.getCell(V))));
                            indicate.setK(getDouble(row.getCell(W)));
                            indicate.setNoneK(Desc2Code.getJudge(getString(row.getCell(X))));
                            indicate.setCl(getDouble(row.getCell(Y)));
                            indicate.setNoneCl(Desc2Code.getJudge(getString(row.getCell(Z))));
                            indicate.setAg(getDouble(row.getCell(AA)));
                            indicate.setNoneAg(Desc2Code.getJudge(getString(row.getCell(AB))));
                            indicate.setNoneUrine(Desc2Code.getJudge(getString(row.getCell(AC))));
                            indicate.setUrineSugar(Desc2Code.getUrineResult(getString(row.getCell(AD))));
                            indicate.setUrineAcetone(Desc2Code.getUrineResult(getString(row.getCell(AE))));
                            indicate.setUrineProtein(Desc2Code.getUrineResult(getString(row.getCell(AF))));
                            indicate.setUrineRicim(getDouble(row.getCell(AG)));
                            indicate.setCheckUrineRicim(Desc2Code.getJudge(getString(row.getCell(AH))));
//                            indicate.setUcr(getDouble(row.getCell(AI)));
//                            indicate.setNoneUcr(Desc2Code.getJudge(getString(row.getCell(AJ))));
                            consult.setDiabetesMellitusType1(Desc2Code.getHas(getString(row.getCell(AI))));
                            consult.setGad(Desc2Code.getAntiResult(getString(row.getCell(AJ))));
                            consult.setIca(Desc2Code.getAntiResult(getString(row.getCell(AK))));
                            consult.setIaa(Desc2Code.getAntiResult(getString(row.getCell(AL))));
                            consult.setIa2(Desc2Code.getAntiResult(getString(row.getCell(AM))));
                            consult.setZnt8(Desc2Code.getAntiResult(getString(row.getCell(AN))));
                            consult.setNoneBlood(Desc2Code.getJudge(getString(row.getCell(AO))));
                            consult.setLeukopenia(getDouble(row.getCell(AP)));
                            consult.setErythrocyte(getDouble(row.getCell(AQ)));
                            consult.setHemoglobin(getDouble(row.getCell(AR)));
                            consult.setHematocritg(getDouble(row.getCell(AS)));
                            consult.setCrpValue(getDouble(row.getCell(AT)));
                            consult.setNoneCrp(Desc2Code.getJudge(getString(row.getCell(AU))));
                            indicate.setUseaNitrogen(getDouble(row.getCell(AV)));
                            indicate.setNoneBun(Desc2Code.getJudge(getString(row.getCell(AW))));
                            indicate.setCreatinine(getDouble(row.getCell(AX)));
                            indicate.setNoneCr(Desc2Code.getJudge(getString(row.getCell(AY))));
                            indicate.setCystatinC(getDouble(row.getCell(AZ)));
                            indicate.setNoneCystatinC(Desc2Code.getJudge(getString(row.getCell(BA))));
                            indicate.setUricAcid(getDouble(row.getCell(BB)));
                            indicate.setNoneUricAcid(Desc2Code.getJudge(getString(row.getCell(BC))));
//                            consult.setNailwork(Desc2Code.getJudge(getString(row.getCell(BF))));
                            indicate.setFt3(getDouble(row.getCell(BD)));
                            indicate.setFt4(getDouble(row.getCell(BE)));
                            indicate.setTsh(getDouble(row.getCell(BF)));
                            indicate.setNoneTiojg(Desc2Code.getJudge(getString(row.getCell(BG))));
                            indicate.setTpoAb(getDouble(row.getCell(BH)));
                            indicate.setNoneTpoab(Desc2Code.getJudge(getString(row.getCell(BI))));
                            indicate.setTgAb(getDouble(row.getCell(BJ)));
                            indicate.setNoneTgab(Desc2Code.getJudge(getString(row.getCell(BK))));
                            indicate.setTriglyceride(getDouble(row.getCell(BL)));
                            indicate.setCholesterol(getDouble(row.getCell(BM)));
                            indicate.setHdl(getDouble(row.getCell(BN)));
                            indicate.setLdl(getDouble(row.getCell(BO)));
                            indicate.setNoneFiobl(Desc2Code.getJudge(getString(row.getCell(BP))));
                            indicate.setApoA1(getDouble(row.getCell(BQ)));
                            indicate.setNoneApoA1(Desc2Code.getJudge(getString(row.getCell(BR))));
                            indicate.setApoB(getDouble(row.getCell(BS)));
                            indicate.setNoneApoB(Desc2Code.getJudge(getString(row.getCell(BT))));
                            indicate.setCa2(getDouble(row.getCell(BU)));
                            indicate.setNoneCa2(Desc2Code.getJudge(getString(row.getCell(BV))));
                            indicate.setP(getDouble(row.getCell(BW)));
                            indicate.setNoneP(Desc2Code.getJudge(getString(row.getCell(BX))));
                            indicate.setVitaminD3(getDouble(row.getCell(BY)));
                            indicate.setNoneVitaminD3(Desc2Code.getJudge(getString(row.getCell(BZ))));
                            consult.setNoneOgtt(Desc2Code.getJudge(getString(row.getCell(CA))));
                            consult.setFastingBloodGlucose(getDouble(row.getCell(CB)));
                            consult.setBloodGlucose2Hour(getDouble(row.getCell(CC)));
                            consult.setFastingCP(getDouble(row.getCell(CD)));
                            consult.setCp2Hour(getDouble(row.getCell(CE)));
                            consult.setFastingInsulin(getDouble(row.getCell(CF)));
                            consult.setInsulin2Hour(getDouble(row.getCell(CG)));
                            indicate.setThyroidUltrasound(Desc2Code.getCTResult(getString(row.getCell(CH))));
                            indicate.setEyeground(Desc2Code.getCTResult(getString(row.getCell(CI))));
                            indicate.setEmg(Desc2Code.getCTResult(getString(row.getCell(CJ))));
                            consult.setDiagnosis(Desc2Code.getConclusion(getString(row.getCell(CK)),
                                    getString(row.getCell(CL)),
                                    getString(row.getCell(CM)),
                                    getString(row.getCell(CN)),
                                    getString(row.getCell(CO)),
                                    getString(row.getCell(CP)),
                                    getString(row.getCell(CQ)),
                                    getString(row.getCell(CR)),
                                    getString(row.getCell(CS)),
                                    getString(row.getCell(CT)),
                                    getString(row.getCell(CU)),
                                    getString(row.getCell(CV))));
                            consult.setDiagnosisName(getString(row.getCell(CW)));
                            indicate.setGen(getString(row.getCell(CX)));
                            row = cureInfo.getRow(i);
                            indicate.setTreatPlan(this.toJson(Desc2Code.getTreatPlan(
                                    getString(row.getCell(C)), getInteger(row.getCell(D)), getString(row.getCell(E)),
                                    getString(row.getCell(F)), getInteger(row.getCell(G)), getString(row.getCell(H)),
                                    getString(row.getCell(I)), getInteger(row.getCell(J)), getString(row.getCell(K)),
                                    getString(row.getCell(L)), getInteger(row.getCell(M)), getString(row.getCell(N)),
                                    getString(row.getCell(O)), getInteger(row.getCell(P)), getString(row.getCell(Q)),
                                    getString(row.getCell(R)), getInteger(row.getCell(S)), getString(row.getCell(T)),
                                    getString(row.getCell(U)))));
                            indicate.setTotalInsulin(getDouble(row.getCell(V)));
                            indicate.setBaseInsulin(getDouble(row.getCell(W)));
                            indicate.setPrandialInsulin(getDouble(row.getCell(X)));
                            indicate.setPremixedInsulin(getDouble(row.getCell(Y)));
                            indicate.setInsulinType(Desc2Code.getInsulinType(getString(row.getCell(Z)),
                                    getString(row.getCell(AA)),
                                            getString(row.getCell(AB)),
                                            getString(row.getCell(AC)),
                                            getString(row.getCell(AD))));
                            consult.setMetformin(getDouble(row.getCell(AE)));
                            consult.setGlyburide(getDouble(row.getCell(AF)));
                            indicate.setBloodGlucoseMonitor(Desc2Code.getBloodCheck(getString(row.getCell(AG))));
                            indicate.setReviewTimes(Desc2Code.getRecheck(getString(row.getCell(AH))));
                            indicate.setHba1cTimes(Desc2Code.getRecheck(getString(row.getCell(AI))));
                            consult.setInterruptInjectInsulin(Desc2Code.getJudge(getString(row.getCell(AJ))));
                            consult.setInterruptDesc(getString(row.getCell(AK)));
                            consult.setEatingDisorder(Desc2Code.getJudge(getString(row.getCell(AL))));
                            consult.setSportUnreasonable(Desc2Code.getJudge(getString(row.getCell(AM))));
                            consult.setTired(Desc2Code.getJudge(getString(row.getCell(AN))));
                            consult.setInfected(Desc2Code.getInfect(getString(row.getCell(AO))));
                            consult.setDisease(getString(row.getCell(AP)));
                            consult.setStimulate(Desc2Code.getJudge(getString(row.getCell(AQ))));
                            consult.setHieDisease(Desc2Code.getJudge(getString(row.getCell(AR))));
                            consult.setIatrogenic(Desc2Code.getJudge(getString(row.getCell(AS))));
                            consult.setPlugging(Desc2Code.getJudge(getString(row.getCell(AT))));
//                            consult.setOtherDka(Desc2Code.getJudge(getString(row.getCell(AU))));
//                            consult.setOtherDkaDetail(getString(row.getCell(AV)));
                            logger.debug("{}", indicate);
                            logger.debug("{}", consult);
                            this.mapper.saveIndicate(indicate);
                            this.mapper.saveConsult(consult);
                        }
                    }
                }

                if (pName.toString().equals("")) {
                    return DdxzResponse.correct("OK");
                } else {
                    return DdxzResponse.correct("数据导入成功，但下列病人需要先导入病人信息：" + pName.toString());
                }
            } catch (Exception var15) {
                logger.error("导入住院信息失败", var15);
                return DdxzResponse.error(ErrorStatus.FAILED_IMPORT_CONSULT);
            }
        }
    }

    private void inportPatient(Sheet sheet) {
        PatientEntity entity = new PatientEntity();
        int count;

        Row row;
        String hospitalNo;
        for (int i = 0; i < sheet.getPhysicalNumberOfRows(); ++i) {
            if (i >= 2) {
                row = sheet.getRow(i);
                hospitalNo = Desc2Code.getHospitalNo(getLongString(row.getCell(B)));
                if("0000000000".equals(hospitalNo)) {
                    continue;
                }
                count = this.mapper.getPatientNumByNameBirthday(Desc2Code.getDesc(row.getCell(A).getStringCellValue()),
                        getDate(row.getCell(F)),
                        hospitalNo);
                if (count <= 0) {
                    entity.setId(CommonUtil.generatorId("t_patient"));
                    entity.setName(Desc2Code.getDesc(getString(row.getCell(A))));
                    entity.setHospitalized(Desc2Code.getHospitalNo(getLongString(row.getCell(B))));
                    entity.setOldName(Desc2Code.getDesc(getString(row.getCell(C))));
                    entity.setGender(Desc2Code.getGenderCode(getString(row.getCell(D))));
                    logger.debug("age cell type {}", row.getCell(E).getCellType().toString());
                    entity.setAge(getDouble(row.getCell(E)));
                    entity.setBirthday(getDate(row.getCell(F)));
                    entity.setNation(Desc2Code.getNation(getString(row.getCell(G))));
                    entity.setAddress(getString(row.getCell(H)));
                    entity.setAddressType(Desc2Code.getAddressType(getString(row.getCell(I))));
                    entity.setConnector(getString(row.getCell(J)));
                    entity.setRelation(Desc2Code.getRelation(getString(row.getCell(K))));
                    logger.debug("count = {}, idx = {}, L type = {}", new Object[]{count, i, row.getCell(L)});
                    entity.setRelationDetail(getString(row.getCell(L)));
                    entity.setMobilePhone(getLongString(row.getCell(M)));
                    entity.setInsurance(Desc2Code.getInsurance(getString(row.getCell(N))));
                    logger.debug("Homemeters cell type {}", row.getCell(O).getCellType().toString());
                    entity.setHomemeters(getInteger(row.getCell(O)));
                    entity.setSalary(getDouble(row.getCell(P)));
                    entity.setHomeEconomy(Desc2Code.getHomeEconomy(getString(row.getCell(Q))));
                    entity.setCurrentDegree(Desc2Code.getDegree(getString(row.getCell(R))));
                    entity.setParentTopDegree(Desc2Code.getParentDegree(getString(row.getCell(S))));
                    entity.setParentVocation(Desc2Code.getVocation(getString(row.getCell(T))));
                    entity.setParentVocationDetail(getString(row.getCell(U)));
                    entity.setParentRelation(Desc2Code.getParentRelation(getString(row.getCell(V))));
                    entity.setSingleParent(Desc2Code.getJudge(getString(row.getCell(W))));
                    entity.setVd(Desc2Code.getJudge(getString(row.getCell(X))));
                    entity.setVdMonths(getInteger(row.getCell(Y)));
                    entity.setAntibiotic(Desc2Code.getAntiResult(getString(row.getCell(Z))));
                    entity.setSickness(Desc2Code.getJudge(getString(row.getCell(AA))));
                    entity.setMotherSickness(getString(row.getCell(AB)));
                    entity.setBirths(getInteger(row.getCell(AC)));
                    entity.setChilds(getInteger(row.getCell(AD)));
                    entity.setWeeks(Desc2Code.getWeeks(getString(row.getCell(AE))));
                    entity.setDeliverType(Desc2Code.getDeliverType(getString(row.getCell(AF))));
                    entity.setWeight(getDouble(row.getCell(AG)));
                    entity.setFeedType(Desc2Code.getFeedType(getString(row.getCell(AH))));
                    entity.setBreast(getInteger(row.getCell(AI)));
                    entity.setMilkMonths(getInteger(row.getCell(AK)));
                    entity.setFeedMonths(getInteger(row.getCell(AJ)));
                    entity.setElePlaySituation(Desc2Code.getElePlayTime(getString(row.getCell(AL))));
                    entity.setSportSituation(Desc2Code.getSportSituation(getString(row.getCell(AM))));
                    entity.setHistory(Desc2Code.getHistory(getString(row.getCell(AN)),
                            getString(row.getCell(AO)),
                            getString(row.getCell(AP)),
                            getString(row.getCell(AQ)),
                            getString(row.getCell(AR)),
                            getString(row.getCell(AS)),
                            getString(row.getCell(AT)),
                            getString(row.getCell(AU))));
                    entity.setHistDetail(getString(row.getCell(AV)));
                    logger.debug(entity.toString());
                    this.mapper.savePatient(entity);
                }
            }
        }
    }

    /**
     * 导入随访信息
     *
     * @param token 令牌
     * @param file  保存有病人随访信息的Excel文件
     * @return 是否导入成功
     */
    @Override
    public DdxzResponse importCourse(String token, MultipartFile file) {
        String userName = this.getUserName(token);
        if (userName == null) {
            logger.error("解析令牌失败", token);
            return DdxzResponse.error(ErrorStatus.INVALID_TOKEN);
        } else {
            boolean old = file.getOriginalFilename().endsWith(".xls");
            new StringBuilder();

            try {
                Workbook workbook = old ? new HSSFWorkbook(file.getInputStream()) : new XSSFWorkbook(file.getInputStream());
                Sheet baseInfo = workbook.getSheetAt(0);
                Sheet checkInfo = workbook.getSheetAt(1);
                Sheet cureInfo = workbook.getSheetAt(2);
                IndicateEntity indicate = new IndicateEntity(2);
                CourseEntity entity = new CourseEntity();
                PatientEntity patient = new PatientEntity();

                for (int rowIdx = 0; rowIdx < baseInfo.getPhysicalNumberOfRows(); ++rowIdx) {
                    if (rowIdx >= 2) {
                        Row row = baseInfo.getRow(rowIdx);
                        entity.setId(CommonUtil.generatorId("t_course"));
                        indicate.setId(entity.getId());
                        indicate.setType(2);
                        entity.setHospitalized(Desc2Code.getHospitalNo(getLongString(row.getCell(B))));
                        String pid = this.mapper.getPatientIdByHospitalNo(entity.getHospitalized());
                        if (null == pid) {
                            patient.setName(getString(row.getCell(A)));
                            patient.setBirthday(DFS.format(null == row.getCell(C) ? null : row.getCell(C).getDateCellValue()));
                            patient.setGender(Desc2Code.getGenderCode(getString(row.getCell(E))));
                            patient.setId(CommonUtil.generatorId("t_patient"));
                            indicate.setPatientId(patient.getId());
                            this.mapper.savePatient(patient);
                        } else {
                            indicate.setPatientId(pid);
                        }

                        indicate.setCheckDate(DFS.format(null == row.getCell(D) ? null : row.getCell(D).getDateCellValue()));
                        indicate.setDiseaseCourse(getDouble(row.getCell(F)));
                        indicate.setDiseaseUnit(Desc2Code.getDateTimeUnit(getString(row.getCell(G))));
                        entity.setCost(getDouble(row.getCell(H)));
                        entity.setNoneSign(Desc2Code.getHas(getString(row.getCell(I))));
                        entity.setSignDetail(getString(row.getCell(J)));
                        indicate.setHeight(getDouble(row.getCell(K)));
                        entity.setHeightLevel(Desc2Code.getLevel(getString(row.getCell(L))));
                        indicate.setWeight(getDouble(row.getCell(M)));
                        entity.setWeightLevel(Desc2Code.getLevel(getString(row.getCell(N))));
                        indicate.setMbi(Desc2Code.getBMI(indicate.getHeight(), indicate.getWeight()));
                        indicate.setSystolicPressure(getDouble(row.getCell(P)));
                        indicate.setDiastolicPressure(getDouble(row.getCell(Q)));
                        indicate.setPuberty(Desc2Code.getHas(getString(row.getCell(R))));
                        entity.setDamage(Desc2Code.getDamage(getString(row.getCell(S))));
                        row = checkInfo.getRow(rowIdx);
                        indicate.setBloodSugar(getDouble(row.getCell(C)));
                        indicate.setCp(getDouble(row.getCell(D)));
                        indicate.setNoneCP(Desc2Code.getJudge(getString(row.getCell(E))));
                        indicate.setInsulin(getDouble(row.getCell(F)));
                        indicate.setNoneInsulin(Desc2Code.getJudge(getString(row.getCell(G))));
                        indicate.setCruorin(getDouble(row.getCell(H)));
                        indicate.setNoneCruorin(Desc2Code.getJudge(getString(row.getCell(I))));
                        indicate.setRicim(getDouble(row.getCell(J)));
                        indicate.setNoneRicim(Desc2Code.getJudge(getString(row.getCell(K))));
                        indicate.setPh(getDouble(row.getCell(L)));
                        indicate.setNonePH(Desc2Code.getJudge(getString(row.getCell(M))));
                        indicate.setHco3(getDouble(row.getCell(N)));
                        indicate.setNoneHco3(Desc2Code.getJudge(getString(row.getCell(O))));
                        indicate.setBe(getDouble(row.getCell(P)));
                        indicate.setNoneBe(Desc2Code.getJudge(getString(row.getCell(Q))));
                        indicate.setNa(getDouble(row.getCell(R)));
                        indicate.setNoneNa(Desc2Code.getJudge(getString(row.getCell(S))));
                        indicate.setK(getDouble(row.getCell(T)));
                        indicate.setNoneK(Desc2Code.getJudge(getString(row.getCell(U))));
                        indicate.setCl(getDouble(row.getCell(V)));
                        indicate.setNoneCl(Desc2Code.getJudge(getString(row.getCell(W))));
                        indicate.setAg(getDouble(row.getCell(X)));
                        indicate.setNoneAg(Desc2Code.getJudge(getString(row.getCell(Y))));
                        indicate.setNoneUrine(Desc2Code.getJudge(getString(row.getCell(Z))));
                        indicate.setUrineSugar(Desc2Code.getUrineResult(getString(row.getCell(AA))));
                        indicate.setUrineAcetone(Desc2Code.getUrineResult(getString(row.getCell(AB))));
                        indicate.setUrineProtein(Desc2Code.getUrineResult(getString(row.getCell(AC))));
                        indicate.setUrineRicim(getDouble(row.getCell(AD)));
                        indicate.setCheckUrineRicim(Desc2Code.getJudge(getString(row.getCell(AE))));
                        indicate.setUcr(getDouble(row.getCell(AF)));
                        indicate.setNoneUcr(Desc2Code.getJudge(getString(row.getCell(AG))));
                        entity.setNoneBlood(Desc2Code.getJudge(getString(row.getCell(AH))));
                        entity.setLeukopenia(getDouble(row.getCell(AI)));
                        entity.setErythrocyte(getDouble(row.getCell(AJ)));
                        entity.setHemoglobin(getDouble(row.getCell(AK)));
                        entity.setHematocritg(getDouble(row.getCell(AL)));
                        indicate.setUseaNitrogen(getDouble(row.getCell(AM)));
                        indicate.setNoneBun(Desc2Code.getJudge(getString(row.getCell(AN))));
                        indicate.setCreatinine(getDouble(row.getCell(AO)));
                        indicate.setNoneCr(Desc2Code.getJudge(getString(row.getCell(AP))));
                        indicate.setCystatinC(getDouble(row.getCell(AQ)));
                        indicate.setNoneCystatinC(Desc2Code.getJudge(getString(row.getCell(AR))));
                        indicate.setUricAcid(getDouble(row.getCell(AS)));
                        indicate.setNoneUricAcid(Desc2Code.getJudge(getString(row.getCell(AT))));
                        indicate.setFt3(getDouble(row.getCell(AU)));
                        indicate.setFt4(getDouble(row.getCell(AV)));
                        indicate.setTsh(getDouble(row.getCell(AW)));
                        indicate.setNoneTiojg(Desc2Code.getJudge(getString(row.getCell(AX))));
                        indicate.setTpoAb(getDouble(row.getCell(AY)));
                        indicate.setNoneTpoab(Desc2Code.getJudge(getString(row.getCell(AZ))));
                        indicate.setTgAb(getDouble(row.getCell(BA)));
                        indicate.setNoneTgab(Desc2Code.getJudge(getString(row.getCell(BB))));
                        indicate.setTriglyceride(getDouble(row.getCell(BC)));
                        indicate.setCholesterol(getDouble(row.getCell(BD)));
                        indicate.setHdl(getDouble(row.getCell(BE)));
                        indicate.setLdl(getDouble(row.getCell(BF)));
                        indicate.setNoneFiobl(Desc2Code.getJudge(getString(row.getCell(BG))));
                        indicate.setApoA1(getDouble(row.getCell(BH)));
                        indicate.setNoneApoA1(Desc2Code.getJudge(getString(row.getCell(BI))));
                        indicate.setApoB(getDouble(row.getCell(BJ)));
                        indicate.setNoneApoB(Desc2Code.getJudge(getString(row.getCell(BK))));
                        indicate.setCa2(getDouble(row.getCell(BL)));
                        indicate.setNoneCa2(Desc2Code.getJudge(getString(row.getCell(BM))));
                        indicate.setP(getDouble(row.getCell(BN)));
                        indicate.setNoneP(Desc2Code.getJudge(getString(row.getCell(BO))));
                        indicate.setVitaminD3(getDouble(row.getCell(BP)));
                        indicate.setNoneVitaminD3(Desc2Code.getJudge(getString(row.getCell(BQ))));
                        indicate.setThyroidUltrasound(Desc2Code.getCTResult(getString(row.getCell(BR))));
                        indicate.setEyeground(Desc2Code.getCTResult(getString(row.getCell(BS))));
                        indicate.setEmg(Desc2Code.getCTResult(getString(row.getCell(BT))));
                        entity.setDiagnosis(Desc2Code.getConclusion(getString(row.getCell(BU)),
                                getString(row.getCell(BV)),
                                getString(row.getCell(BW)),
                                getString(row.getCell(BX)),
                                getString(row.getCell(BY)),
                                getString(row.getCell(BZ)),
                                getString(row.getCell(CA)),
                                getString(row.getCell(CB)),
                                getString(row.getCell(CC)),
                                getString(row.getCell(CD)),
                                getString(row.getCell(CE)),
                                getString(row.getCell(CF))));
                        entity.setDiagnosisName(getString(row.getCell(CH)));
                        indicate.setGen(getString(row.getCell(CI)));
                        row = cureInfo.getRow(rowIdx);
                        entity.setHypoglycemiaFreq(Desc2Code.getFrequence(getString(row.getCell(C))));
                        entity.setSevereHypoglycemiaFreq(Desc2Code.getFrequence(getString(row.getCell(D))));
                        indicate.setTreatPlan(this.toJson(Desc2Code.getTreatPlan(getString(row.getCell(E)),
                                getInteger(row.getCell(F)),
                                getString(row.getCell(G)),
                                getString(row.getCell(H)),
                                getInteger(row.getCell(I)),
                                getString(row.getCell(J)),
                                getString(row.getCell(K)),
                                getInteger(row.getCell(L)),
                                getString(row.getCell(M)),
                                getString(row.getCell(N)),
                                getInteger(row.getCell(O)),
                                getString(row.getCell(P)),
                                getString(row.getCell(Q)),
                                getInteger(row.getCell(R)),
                                getString(row.getCell(S)),
                                getString(row.getCell(T)),
                                getInteger(row.getCell(U)),
                                getString(row.getCell(V)),
                                getString(row.getCell(W)))));
                        indicate.setTotalInsulin(getDouble(row.getCell(X)));
                        indicate.setBaseInsulin(getDouble(row.getCell(Y)));
                        indicate.setPrandialInsulin(getDouble(row.getCell(Z)));
                        indicate.setPremixedInsulin(getDouble(row.getCell(AA)));
                        indicate.setInsulinType(Desc2Code.getInsulinType(getString(row.getCell(AB)),
                                getString(row.getCell(AC)),
                                getString(row.getCell(AD)),
                                getString(row.getCell(AE)),
                                getString(row.getCell(AF))));
                        entity.setMetformin(getDouble(row.getCell(AG)));
                        entity.setGlyburide(getDouble(row.getCell(AH)));
                        indicate.setBloodGlucoseMonitor(Desc2Code.getBloodCheck(getString(row.getCell(AI))));
                        indicate.setReviewTimes(Desc2Code.getRecheck(getString(row.getCell(AJ))));
                        indicate.setHba1cTimes(Desc2Code.getRecheck(getString(row.getCell(AK))));
                        entity.setDietaryStatus(Desc2Code.getDietaryStatus(getString(row.getCell(AL))));
                        entity.setMotionCondition(Desc2Code.getMotionCondition(getString(row.getCell(AM))));
                        entity.setMentalHealth(Desc2Code.getMentalHealth(getString(row.getCell(AN))));
                        logger.debug("{}", indicate);
                        logger.debug("{}", entity);
                        this.mapper.saveIndicate(indicate);
                        this.mapper.saveCourse(entity);
                    }
                }

                return DdxzResponse.correct(ConstData.OK_MESSAGE);
            } catch (Exception var16) {
                logger.error("导入随访信息失败", var16);
                return DdxzResponse.error(ErrorStatus.FAILED_IMPORT_COURSE);
            }
        }
    }

    /**
     * 导入住院信息
     *
     * @param file 文件信息
     * @return 是否导入成功
     */
    @Override
    public DdxzResponse importConsult(ConsultFile file) {
        byte[] content = Base64Util.decode(file.getContent());
        File excelFile = new File(file.getFileName());
        try(FileOutputStream fos = new FileOutputStream(excelFile)) {
            fos.write(content);
            fos.flush();
        } catch (Exception e) {
            e.printStackTrace();
        }

        DdxzResponse response = importConsult(excelFile);
        excelFile.delete();

        return response;
    }

    private DdxzResponse importConsult(File excelFile) {
        boolean old = excelFile.getName().endsWith(".xls");
        StringBuilder pName = new StringBuilder();

        try (FileInputStream fis = new FileInputStream(excelFile)) {
            Workbook workbook = old ? new HSSFWorkbook(fis) : new XSSFWorkbook(fis);
            Sheet patientInfo = workbook.getSheetAt(0);
            Sheet baseInfo = workbook.getSheetAt(1);
            Sheet checkInfo = workbook.getSheetAt(2);
            Sheet cureInfo = workbook.getSheetAt(3);
            IndicateEntity indicate = new IndicateEntity(1);
            ConsultEntity consult = new ConsultEntity();

            inportPatient(patientInfo);

            for (int i = 0; i < baseInfo.getPhysicalNumberOfRows(); ++i) {
                if (i >= 2) {
                    Row row = baseInfo.getRow(i);
                    logger.info("第{}行", i);
                    consult.setHospitalized(Desc2Code.getHospitalNo(getLongString(row.getCell(B))));
                    if("0000000000".equals(consult.getHospitalized())) {
                        continue;
                    }

                    consult.setId(CommonUtil.generatorId("t_consult"));
                    indicate.setId(consult.getId());
                    indicate.setType(1);
                    String pid = this.mapper.getPatientIdByHospitalNo(consult.getHospitalized());
                    if (null == pid) {
                        pName.append(", ");
                        pName.append(row.getCell(A).getStringCellValue());
                    } else {
                        indicate.setPatientId(pid);
                        indicate.setCheckDate(getDate(row.getCell(C)));
                        consult.setHospitalizedNum(getInteger(row.getCell(D)));
                        indicate.setDiseaseCourse(getDouble(row.getCell(E)));
                        indicate.setDiseaseUnit(Desc2Code.getDateTimeUnit(getString(row.getCell(F))));
                        consult.setDiagnoseDate(getDate(row.getCell(G)));
                        consult.setFocusFood(Desc2Code.getJudge(getString(row.getCell(H))));
                        consult.setHospitalizedDays(getInteger(row.getCell(I)));
                        consult.setHospitalizedCost(getDouble(row.getCell(J)));
                        indicate.setHeight(getDouble(row.getCell(K)));
                        indicate.setWeight(getDouble(row.getCell(L)));
                        indicate.setMbi(Desc2Code.getBMI(indicate.getHeight(), indicate.getWeight()));
                        consult.setWaistline(getDouble(row.getCell(N)));
                        consult.setHipline(getDouble(row.getCell(O)));
                        consult.setWaistHeight(Desc2Code.getWaistHeight(consult.getWaistline(), indicate.getHeight()));
                        consult.setHeartRate(getInteger(row.getCell(S)));
                        indicate.setSystolicPressure(getDouble(row.getCell(T)));
                        indicate.setDiastolicPressure(getDouble(row.getCell(U)));
                        indicate.setPuberty(Desc2Code.getHas(getString(row.getCell(V))));
                        consult.setDisplayTime(getInteger(row.getCell(W)));
                        consult.setDisplayTimeUnit(Desc2Code.getDateTimeUnit(getString(row.getCell(X))));
                        consult.setSymptom(Desc2Code.getSymptom(getString(row.getCell(Y)),
                                getString(row.getCell(Z)),
                                getString(row.getCell(AA)),
                                getString(row.getCell(AB)),
                                getString(row.getCell(AC)),
                                getString(row.getCell(AD)),
                                getString(row.getCell(AE)),
                                getString(row.getCell(AF)),
                                getString(row.getCell(AG)),
                                getString(row.getCell(AH)),
                                getString(row.getCell(AI)),
                                getString(row.getCell(AJ)),
                                getString(row.getCell(AK)),
                                getString(row.getCell(AL)),
                                getString(row.getCell(AM)),
                                getString(row.getCell(AN)),
                                getString(row.getCell(AO))));
                        consult.setSign(Desc2Code.getSign(getString(row.getCell(AP)),
                                getString(row.getCell(AQ)),
                                getString(row.getCell(AR)),
                                getString(row.getCell(AS)),
                                getString(row.getCell(AT)),
                                getString(row.getCell(AU)),
                                getString(row.getCell(AV)),
                                getString(row.getCell(AW)),
                                getString(row.getCell(AX)),
                                getString(row.getCell(AY)),
                                getString(row.getCell(AZ))));
                        consult.setDka(Desc2Code.getDka(getString(row.getCell(BA)),
                                getString(row.getCell(BB))));
                        row = checkInfo.getRow(i);
                        indicate.setBloodSugar(getDouble(row.getCell(C)));
                        consult.setPrecondition(Desc2Code.getPreconditon(getString(row.getCell(D))));
                        indicate.setCp(getDouble(row.getCell(E)));
                        indicate.setNoneCP(Desc2Code.getJudge(getString(row.getCell(F))));
                        indicate.setInsulin(getDouble(row.getCell(G)));
                        indicate.setNoneInsulin(Desc2Code.getJudge(getString(row.getCell(H))));
                        indicate.setCruorin(getDouble(row.getCell(I)));
                        indicate.setNoneCruorin(Desc2Code.getJudge(getString(row.getCell(J))));
                        indicate.setRicim(getDouble(row.getCell(K)));
                        indicate.setNoneRicim(Desc2Code.getJudge(getString(row.getCell(L))));
                        indicate.setRericim(getDouble(row.getCell(M)));
                        indicate.setNoneRericim(Desc2Code.getJudge(getString(row.getCell(N))));
                        indicate.setPh(getDouble(row.getCell(O)));
                        indicate.setNonePH(Desc2Code.getJudge(getString(row.getCell(P))));
                        indicate.setHco3(getDouble(row.getCell(Q)));
                        indicate.setNoneHco3(Desc2Code.getJudge(getString(row.getCell(R))));
                        indicate.setBe(getDouble(row.getCell(S)));
                        indicate.setNoneBe(Desc2Code.getJudge(getString(row.getCell(T))));
                        indicate.setNa(getDouble(row.getCell(U)));
                        indicate.setNoneNa(Desc2Code.getJudge(getString(row.getCell(V))));
                        indicate.setK(getDouble(row.getCell(W)));
                        indicate.setNoneK(Desc2Code.getJudge(getString(row.getCell(X))));
                        indicate.setCl(getDouble(row.getCell(Y)));
                        indicate.setNoneCl(Desc2Code.getJudge(getString(row.getCell(Z))));
                        indicate.setAg(getDouble(row.getCell(AA)));
                        indicate.setNoneAg(Desc2Code.getJudge(getString(row.getCell(AB))));
                        indicate.setNoneUrine(Desc2Code.getJudge(getString(row.getCell(AC))));
                        indicate.setUrineSugar(Desc2Code.getUrineResult(getString(row.getCell(AD))));
                        indicate.setUrineAcetone(Desc2Code.getUrineResult(getString(row.getCell(AE))));
                        indicate.setUrineProtein(Desc2Code.getUrineResult(getString(row.getCell(AF))));
                        indicate.setUrineRicim(getDouble(row.getCell(AG)));
                        indicate.setCheckUrineRicim(Desc2Code.getJudge(getString(row.getCell(AH))));
//                            indicate.setUcr(getDouble(row.getCell(AI)));
//                            indicate.setNoneUcr(Desc2Code.getJudge(getString(row.getCell(AJ))));
                        consult.setDiabetesMellitusType1(Desc2Code.getHas(getString(row.getCell(AI))));
                        consult.setGad(Desc2Code.getAntiResult(getString(row.getCell(AJ))));
                        consult.setIca(Desc2Code.getAntiResult(getString(row.getCell(AK))));
                        consult.setIaa(Desc2Code.getAntiResult(getString(row.getCell(AL))));
                        consult.setIa2(Desc2Code.getAntiResult(getString(row.getCell(AM))));
                        consult.setZnt8(Desc2Code.getAntiResult(getString(row.getCell(AN))));
                        consult.setNoneBlood(Desc2Code.getJudge(getString(row.getCell(AO))));
                        consult.setLeukopenia(getDouble(row.getCell(AP)));
                        consult.setErythrocyte(getDouble(row.getCell(AQ)));
                        consult.setHemoglobin(getDouble(row.getCell(AR)));
                        consult.setHematocritg(getDouble(row.getCell(AS)));
                        consult.setCrpValue(getDouble(row.getCell(AT)));
                        consult.setNoneCrp(Desc2Code.getJudge(getString(row.getCell(AU))));
                        indicate.setUseaNitrogen(getDouble(row.getCell(AV)));
                        indicate.setNoneBun(Desc2Code.getJudge(getString(row.getCell(AW))));
                        indicate.setCreatinine(getDouble(row.getCell(AX)));
                        indicate.setNoneCr(Desc2Code.getJudge(getString(row.getCell(AY))));
                        indicate.setCystatinC(getDouble(row.getCell(AZ)));
                        indicate.setNoneCystatinC(Desc2Code.getJudge(getString(row.getCell(BA))));
                        indicate.setUricAcid(getDouble(row.getCell(BB)));
                        indicate.setNoneUricAcid(Desc2Code.getJudge(getString(row.getCell(BC))));
//                            consult.setNailwork(Desc2Code.getJudge(getString(row.getCell(BF))));
                        indicate.setFt3(getDouble(row.getCell(BD)));
                        indicate.setFt4(getDouble(row.getCell(BE)));
                        indicate.setTsh(getDouble(row.getCell(BF)));
                        indicate.setNoneTiojg(Desc2Code.getJudge(getString(row.getCell(BG))));
                        indicate.setTpoAb(getDouble(row.getCell(BH)));
                        indicate.setNoneTpoab(Desc2Code.getJudge(getString(row.getCell(BI))));
                        indicate.setTgAb(getDouble(row.getCell(BJ)));
                        indicate.setNoneTgab(Desc2Code.getJudge(getString(row.getCell(BK))));
                        indicate.setTriglyceride(getDouble(row.getCell(BL)));
                        indicate.setCholesterol(getDouble(row.getCell(BM)));
                        indicate.setHdl(getDouble(row.getCell(BN)));
                        indicate.setLdl(getDouble(row.getCell(BO)));
                        indicate.setNoneFiobl(Desc2Code.getJudge(getString(row.getCell(BP))));
                        indicate.setApoA1(getDouble(row.getCell(BQ)));
                        indicate.setNoneApoA1(Desc2Code.getJudge(getString(row.getCell(BR))));
                        indicate.setApoB(getDouble(row.getCell(BS)));
                        indicate.setNoneApoB(Desc2Code.getJudge(getString(row.getCell(BT))));
                        indicate.setCa2(getDouble(row.getCell(BU)));
                        indicate.setNoneCa2(Desc2Code.getJudge(getString(row.getCell(BV))));
                        indicate.setP(getDouble(row.getCell(BW)));
                        indicate.setNoneP(Desc2Code.getJudge(getString(row.getCell(BX))));
                        indicate.setVitaminD3(getDouble(row.getCell(BY)));
                        indicate.setNoneVitaminD3(Desc2Code.getJudge(getString(row.getCell(BZ))));
                        consult.setNoneOgtt(Desc2Code.getJudge(getString(row.getCell(CA))));
                        consult.setFastingBloodGlucose(getDouble(row.getCell(CB)));
                        consult.setBloodGlucose2Hour(getDouble(row.getCell(CC)));
                        consult.setFastingCP(getDouble(row.getCell(CD)));
                        consult.setCp2Hour(getDouble(row.getCell(CE)));
                        consult.setFastingInsulin(getDouble(row.getCell(CF)));
                        consult.setInsulin2Hour(getDouble(row.getCell(CG)));
                        indicate.setThyroidUltrasound(Desc2Code.getCTResult(getString(row.getCell(CH))));
                        indicate.setEyeground(Desc2Code.getCTResult(getString(row.getCell(CI))));
                        indicate.setEmg(Desc2Code.getCTResult(getString(row.getCell(CJ))));
                        consult.setDiagnosis(Desc2Code.getConclusion(getString(row.getCell(CK)),
                                getString(row.getCell(CL)),
                                getString(row.getCell(CM)),
                                getString(row.getCell(CN)),
                                getString(row.getCell(CO)),
                                getString(row.getCell(CP)),
                                getString(row.getCell(CQ)),
                                getString(row.getCell(CR)),
                                getString(row.getCell(CS)),
                                getString(row.getCell(CT)),
                                getString(row.getCell(CU)),
                                getString(row.getCell(CV))));
                        consult.setDiagnosisName(getString(row.getCell(CW)));
                        indicate.setGen(getString(row.getCell(CX)));
                        row = cureInfo.getRow(i);
                        indicate.setTreatPlan(this.toJson(Desc2Code.getTreatPlan(
                                getString(row.getCell(C)), getInteger(row.getCell(D)), getString(row.getCell(E)),
                                getString(row.getCell(F)), getInteger(row.getCell(G)), getString(row.getCell(H)),
                                getString(row.getCell(I)), getInteger(row.getCell(J)), getString(row.getCell(K)),
                                getString(row.getCell(L)), getInteger(row.getCell(M)), getString(row.getCell(N)),
                                getString(row.getCell(O)), getInteger(row.getCell(P)), getString(row.getCell(Q)),
                                getString(row.getCell(R)), getInteger(row.getCell(S)), getString(row.getCell(T)),
                                getString(row.getCell(U)))));
                        indicate.setTotalInsulin(getDouble(row.getCell(V)));
                        indicate.setBaseInsulin(getDouble(row.getCell(W)));
                        indicate.setPrandialInsulin(getDouble(row.getCell(X)));
                        indicate.setPremixedInsulin(getDouble(row.getCell(Y)));
                        indicate.setInsulinType(Desc2Code.getInsulinType(getString(row.getCell(Z)),
                                getString(row.getCell(AA)),
                                getString(row.getCell(AB)),
                                getString(row.getCell(AC)),
                                getString(row.getCell(AD))));
                        consult.setMetformin(getDouble(row.getCell(AE)));
                        consult.setGlyburide(getDouble(row.getCell(AF)));
                        indicate.setBloodGlucoseMonitor(Desc2Code.getBloodCheck(getString(row.getCell(AG))));
                        indicate.setReviewTimes(Desc2Code.getRecheck(getString(row.getCell(AH))));
                        indicate.setHba1cTimes(Desc2Code.getRecheck(getString(row.getCell(AI))));
                        consult.setInterruptInjectInsulin(Desc2Code.getJudge(getString(row.getCell(AJ))));
                        consult.setInterruptDesc(getString(row.getCell(AK)));
                        consult.setEatingDisorder(Desc2Code.getJudge(getString(row.getCell(AL))));
                        consult.setSportUnreasonable(Desc2Code.getJudge(getString(row.getCell(AM))));
                        consult.setTired(Desc2Code.getJudge(getString(row.getCell(AN))));
                        consult.setInfected(Desc2Code.getInfect(getString(row.getCell(AO))));
                        consult.setDisease(getString(row.getCell(AP)));
                        consult.setStimulate(Desc2Code.getJudge(getString(row.getCell(AQ))));
                        consult.setHieDisease(Desc2Code.getJudge(getString(row.getCell(AR))));
                        consult.setIatrogenic(Desc2Code.getJudge(getString(row.getCell(AS))));
                        consult.setPlugging(Desc2Code.getJudge(getString(row.getCell(AT))));
//                            consult.setOtherDka(Desc2Code.getJudge(getString(row.getCell(AU))));
//                            consult.setOtherDkaDetail(getString(row.getCell(AV)));
                        logger.debug("{}", indicate);
                        logger.debug("{}", consult);
                        this.mapper.saveIndicate(indicate);
                        this.mapper.saveConsult(consult);
                    }
                }
            }

            if (pName.toString().equals("")) {
                return DdxzResponse.correct("OK");
            } else {
                return DdxzResponse.correct("数据导入成功，但下列病人需要先导入病人信息：" + pName.toString());
            }
        } catch (Exception var15) {
            logger.error("导入住院信息失败", var15);
            return DdxzResponse.error(ErrorStatus.FAILED_IMPORT_CONSULT);
        }
    }

    private String getUserName(String token) {
        Map<String, Object> claim = jwtUtil.getBody(token);
        return claim == null ? null : claim.get("username").toString();
    }

    private Double getDouble(Cell cell) {
        String tmp = getString(cell);
        if (StringUtil.isEmpty(tmp)) {
            return null;
        }

        tmp = tmp.replaceAll("[^(-|+)?(\\d+)*.?\\d+]", "");
        if (StringUtil.isEmpty(tmp)) {
            return null;
        }

        return StringUtil.toDouble(tmp);
    }

    private String getDate(Cell cell) {
        if(cell == null) {
            return null;
        }

        switch (cell.getCellType()) {
            case STRING:
                return cell.getStringCellValue();
            case NUMERIC:
                return DFS.format(cell.getDateCellValue());
            default:
                return cell.toString();
        }
    }

    private Integer getInteger(Cell cell) {
        String tmp = getString(cell);
        if (StringUtil.isEmpty(tmp)) {
            return null;
        }

        tmp = tmp.replaceAll("[^(-|+)?(\\d+)*.?\\d+]", "");
        if (StringUtil.isEmpty(tmp)) {
            return null;
        }

        return StringUtil.toDouble(tmp).intValue();
    }

    private String getLongString(Cell cell) {
        if (null == cell) {
            return "";
        }

        switch (cell.getCellType()) {
            case NUMERIC:
                return String.valueOf((long) cell.getNumericCellValue());
            case STRING:
                return cell.getStringCellValue().replaceAll("[^(-|+)?(\\d+)*.?\\d+]", "");
            case BLANK:
                return "";
            default:
                throw new RuntimeException(String.format("第%d行第%d列 数值错误", cell.getRowIndex(), cell.getColumnIndex()));
        }
    }

    private String getString(Cell cell) {
        if (null == cell) {
            return "";
        }

        switch (cell.getCellType()) {
            case STRING:
                return cell.getStringCellValue();
            case NUMERIC:
                return String.valueOf(cell.getNumericCellValue());
            default:
                return "";
        }
    }

    private List<String> toJson(List<TreatPlan> treatPlanList) {
        if (treatPlanList == null) {
            return null;
        } else {
            List<String> rst = new ArrayList(treatPlanList.size());
            treatPlanList.forEach((item) -> {
                rst.add(JSONObject.toJSONString(item));
            });
            return rst;
        }
    }

    private ErrorStatus checkIndicate(IndicateEntity entity) {
        if (entity == null) {
            logger.warn("创建实体类对象失败");
            return SYSTEM_ERROR;
        } else {
            try {
                if (entity.getHeight() != null && entity.getHeight() != 0.0) {
                    entity.setMbi(entity.getWeight() / (entity.getHeight() * entity.getHeight()));
                } else {
                    entity.setMbi(null);
                }

                return CHECK_PASS;
            } catch (Exception var3) {
                return SYSTEM_ERROR;
            }
        }
    }

    private ErrorStatus checkConsult(ConsultEntity domain, IndicateEntity indicate) {
        if (indicate.getHeight() != null && indicate.getHeight() != 0.0) {
            domain.setWaistHeight(domain.getWaistline() / indicate.getHeight());
        } else {
            domain.setWaistHeight(null);
        }

        return ErrorStatus.CHECK_PASS;
    }

    private List<TreatPlan> toPlan(List<String> jsonList) {
        if (jsonList == null) {
            return null;
        } else {
            List<TreatPlan> rst = new ArrayList(jsonList.size());
            jsonList.forEach((item) -> {
                rst.add(JSONObject.toJavaObject(JSONObject.parseObject(item), TreatPlan.class));
            });
            return rst;
        }
    }

    private final DdxzJwtUtil jwtUtil = new DdxzJwtUtil(600000L);
    private final InputMapper mapper;
    private static final SimpleDateFormat DFS = new SimpleDateFormat("yyyy-MM-dd");
    private static final Logger logger = LoggerFactory.getLogger(InputServiceImpl.class);
    private static final Pattern pattern = Pattern.compile("\\d+");

    public InputServiceImpl(InputMapper mapper) {
        this.mapper = mapper;
    }
}
